﻿@{
    ViewBag.Title = "RefrigerationIndex";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head
{
    @Html.Css("EditForm")
    @Html.Js("datepicker")
    @Html.Css("dp")
    <script type="text/javascript">
        var mainheight = document.documentElement.clientHeight;
        var mainWidth = document.documentElement.clientWidth - 10;
        $(document).ready(function () {
            var otherpm = $("#title").height() + $("#findDiv").height(); // 290;
            var gh = mainheight - otherpm - 80;
            var option = {
                height: gh,
                width: mainWidth,
                url: '@Url.Action("GetListNew")',
                dataType: 'json',
                colModel: [
                    { display: '编号', name: 'ID', width: 60, sortable: false, align: 'left', hide: true, iskey: true },
                    { display: '班次编号', name: 'BanCiID', width: 100, sortable: false, hide: true, align: 'left' },
                    { display: '日期', name: 'RDate', width: 100, sortable: false, hide: false, align: 'left' },
			        { display: '班次', name: 'BanCi', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '操作员', name: 'OperatorID', width: 100, sortable: false, hide: false, align: 'left' }
				],
                buttons: [
                            { name: 'Edit', displayname: "修改", title: "编辑", bclass: 'edit', onpress: toolbarItemEdit_onclick },
                            { separator: true }
                         ],
                singleselected: false,
                sortname: "Sequence",
                sortorder: "asc",
                title: false,
                usepager: true,
                page: 1,
                rp: 30,
                rpOptions: [10, 15, 20, 30],
                showcheckbox: true,
                selectedonclick: true, //点击行是否选中
                rowbinddata: true,
                query: $("#SDateTime").val() + "," + $("#EDateTime").val() + "," + $("#BanCi :selected").val()
            };
            var instockgrid = $("#TableList").flexigrid(option);


            function toolbarItemEdit_onclick(cmd) {
                var items = $(instockgrid).getSelectedRows();
                if (items.length == 0) {
                    showLoadingMsg("请选择要修改的记录!", { left: 400, top: 2 }, true, 3000);
                    return false;
                }
                if (items.length > 1) {
                    showLoadingMsg("只能选择一个要修改的记录!", { left: 400, top: 6 }, true, 3000);
                    return false;
                }
                var vDateTime = items[0][2];
                var vBanCi = items[0][1];
                OpenModelWindow('@Url.Action("ReportV")?DateTime=' + vDateTime + '&BanCi=' + vBanCi,
                                   { width: 850, height: 500, caption: "修改制冷记录", onclose: refresh });
            }

            $("#btnQueryList").click(function () {
                select();
            });
            function select() {
                var vST = $("#SDateTime").val();
                var vET = $("#EDateTime").val();
                var vBanCi = $("#BanCi :selected").val();
                option.query = vST + "," + vET + "," + vBanCi;
                option.newp = 0;
                $("#TableList").flexOptions(option).flexReload();
            }
            function refresh() {
                showLoadingMsg("保存成功", { left: 200, top: 6 }, true, 3000);
                $("#TableList").flexReload();
            }

            //            var vDateTime = $("#DateTime").val();
            //            var vBanCi = $("#BanCi :selected").val();


            //            $("#btnQueryList").click(function () {
            //                var vDateTime = $("#DateTime").val();
            //                var vBanCi = $("#BanCi :selected").val();
            //                OpenModelWindow('@Url.Action("ReportV")?DateTime=' + vDateTime + '&BanCi=' + vBanCi,
            //                             { width: 700, height: 500, caption: "报表", onclose: refresh });
            //            });
            $("#btnExport").click(function () {
                var items = $(instockgrid).getSelectedRows();
                if (items.length == 0) {
                    showLoadingMsg("请选择要导出的记录!", { left: 400, top: 2 }, true, 3000);
                    return false;
                }
                if (items.length > 1) {
                    showLoadingMsg("只能选择一个要导出的记录!", { left: 400, top: 6 }, true, 3000);
                    return false;
                }
                var vDateTime = items[0][2];
                var vBanCi = items[0][1];
                var strulr = "ReportOut?DateTime=" + vDateTime + "&BanCi=" + vBanCi;
                var subwin = window.open(strulr, "", "menubar=no,toolbar=no,status=no,resizable=no,scrollbars=yes");
                subwin.moveTo(0, 0);
                subwin.resizeTo(window.screen.availWidth, window.screen.availHeight);
                return false;
            });
        });
    </script>
}
<div id="container">
    <div id="mainContent">
        <div id="title" class="title">
            制冷记录</div>
        <div id="findDiv">
            <table>
                <tr>
                    <td style="text-align: right; width: 80px;">
                        开始日期：
                    </td>
                    <td>
                        @Html.TextBox("SDateTime", DateTime.Now.Date.ToString("yyyy-MM-dd"), new { @ReadOnly = true, @style = "width:140px;", @class = "Wdate", onfocus = "WdatePicker({vel:'C1SignInTime.BeginTime',dateFmt:'yyyy-MM-dd'})" })
                    </td>
                    <td style="text-align: right; width: 80px;">
                        结束日期：
                    </td>
                    <td>
                        @Html.TextBox("EDateTime", DateTime.Now.Date.ToString("yyyy-MM-dd"), new { @ReadOnly = true, @style = "width:140px;", @class = "Wdate", onfocus = "WdatePicker({vel:'C1SignInTime.BeginTime',dateFmt:'yyyy-MM-dd'})" })
                    </td>
                    <td style="text-align: right; width: 80px;">
                        班次:
                    </td>
                    <td>
                        @Html.DropDownList("BanCi",
                                   ViewData["BanCi"] as IEnumerable<SelectListItem>,
                                   new { @style = "width:150px; height:22px; font-size:13px;" })
                    </td>
                    <td>
                        <a id="btnQueryList" class="button" href="javascript:void(0);"><span>查 询</span></a>
                        <a id="btnExport" class="button" href="javascript:void(0);"><span>导 出</span></a>
                    </td>
                </tr>
            </table>
        </div>
        <table id="TableList" style="display: none;">
        </table>
    </div>
</div>

